package org.ricks.condition2.test.entity;

import org.ricks.condition2.Condition;
import org.ricks.condition2.ConditionBinder;
import org.ricks.condition2.ConditionManager;

public class Task {
    private final int taskId;
    private final Condition condition;
    private final String playerId;

    public Task(int taskId, String playerId, Condition condition, Runnable onComplete) {
        this.taskId = taskId;
        this.playerId = playerId;
        this.condition = condition;
        // 绑定完成回调
        ConditionBinder.getInstance().bind(condition, (pId, cond) -> {
            if (pId.equals(playerId)) onComplete.run();
        });
    }

    public void start() {
        ConditionManager.ME().register(condition);
    }
}
